<?php 
$diadiemdulichs = $viewModel->get('diadiemdulichs'); 
$sodiadiem = $viewModel->get('sodiadiem'); 
$tranghientai = $viewModel->get('tranghientai'); 
$sotrang = ceil($sodiadiem/ROWOFPAGE);
include 'views/Include/alert.php';
?>
 

    <div class="container-fluid" style="width:97%">
      <div class="row">
        
        <div class="col-sm-12 col-md-12">
          <h1 class="page-header">Địa điểm du lịch</h1>

            <div class="row header1">
          <div class="col-xs-12 col-md-6">
            <p>
            <a href="<?php echo BASE_URL.'diadiemdulich/create' ?>" class="btn btn-success">Thêm địa điểm mới</a>
          </p>
          </div>
          <form action="search.php" method="post" name="form_search" onsubmit="return validation();">
            <div class="col-xs-6 col-md-4">
              <input name="keyword" type="text" class="form-control" id="exampleInputPassword1" placeholder="Nhập tên địa điểm cần tìm">
            </div>
            <div class="col-xs-6 col-md-2">
              <p>             
              <button type="submit" class="btn btn-success">Tìm kiếm</button>
            </p>
            </div>
          </form>
      </div>      
      
      <div class="row">
        <?php
          if($diadiemdulichs == NULL){
            echo 'Chưa có địa điểm du lịch';
          }else{
          ?>
        <form action="<?php echo BASE_URL.'diadiemdulich/delete'; ?>" method="POST" onsubmit="return ConfirmChoiceDeleteMulti();">
        <table class="table table-striped table-bordered">
                  <thead>
                    <tr>                      
                      <th>Tên địa điểm</th>
                      <th>Địa chỉ</th>
                      <th>Loại địa điểm</th>                                    
                      <th>Tỉnh thành</th>                                    
                      <th>Thao tác</th>
                    </tr>
                  </thead>
                  <tbody>
                  <?php foreach ($diadiemdulichs as $diadiemdulich) { ?>                                    
                      <tr class="success">                        
                        <td><?php echo $diadiemdulich->TenDiem; ?></td>                      
                        <td><?php echo $diadiemdulich->DiaChi; ?></td> 
                        <td><?php echo $diadiemdulich->TenLoaiDiaDiem; ?></td>                      
                        <td><?php echo $diadiemdulich->TenTinh; ?></td>                    
                        <td width=250>
                        <a class="btn btn-info" target="_blank" href="<?php echo BASE_URL.'diadiemdulich/place/'.$diadiemdulich->Alias; ?>"><span class="glyphicon glyphicon-eye-open"></span></a>
                        &nbsp
                        <a class="btn btn-success" href="<?php echo BASE_URL.'diadiemdulich/update/'.$diadiemdulich->Id; ?>"><span class="glyphicon glyphicon-edit"></span></a>
                        &nbsp
                        <a class="btn btn-danger" href="#" onclick="ConfirmChoiceDelete('<?php echo BASE_URL.'diadiemdulich/delete/'.$diadiemdulich->Id; ?>'); return false;"><span class="glyphicon glyphicon-remove-sign"></span></a>
                        </td>
                      </tr>
                    
                    <?php } ?>

                  </tbody>
          </table>
          </form>
             <?php } ?>

      </div>
      <div class="row">
        <div class="col-md-10">
          <?php 
                if($tranghientai>1){echo '<a class="btn btn-success" href="'.BASE_URL.'diadiemdulich/'.($tranghientai-1).'">Trang trước</a>';}
                echo '&nbsp;';
          for ($i=1 ; $i<=$sotrang ; $i++) {
            if ($i == $tranghientai) {
                   echo $i;
                   echo '&nbsp;';
            } 
            else {
                  echo '<a class="btn btn-info" href="'.BASE_URL.'diadiemdulich/'.$i.'">'.$i.'</a>';
                  echo '&nbsp;';
            }
          }
          if($tranghientai<$sotrang){echo '<a class="btn btn-success" href="'.BASE_URL.'diadiemdulich/'.($tranghientai+1).'"">Trang sau</a>';}
        ?>
        
        </div>
        <div class="col-md-2">
          <p>Tổng số địa điểm hiện tại: <?php echo $sodiadiem ?></p>
        </div>
      </div>
        </div>
      </div>
    </div>